package com.tbit.uqbike.object.view;

import com.tbit.uqbike.constant.MachineAbnormalConstant;
import com.tbit.uqbike.constant.MachinePosConstant;
import com.tbit.uqbike.object.pojo.*;

import java.util.List;
import java.util.Objects;

/**
 * 设备信息
 *
 * @author Leon
 * 2019年11月12日 上午11:38:14
 */
public class MachineInfo {
    /**
     * 最后状态信息
     */
    private MachineStatus machineStatus;
    /**
     * 最后骑行订单
     */
    private RideLogEx rideLog;
    /**
     * 归属站点信息
     */
    private ParkPoint parkPoint;
    /**
     * 车辆展示状态
     */
    private MachineShowStatus machineShowStatus;
    /**
     * 最后扫码人
     */
    private MachineLastUse machineLastUse;
    /**
     * 区域id
     */
    private Integer accountId;

    /**
     * 区域id
     */
    private Integer machineFunctionType;

    public static void initMachineParkState(MachineShowStatus machineShowStatus, List<MachineAbnormal> machineAbnormalList) {
        // 默认是正常状态
        Integer temp = MachinePosConstant.POS_AREA_IN;
        if (null != machineAbnormalList) {
            for (MachineAbnormal ma : machineAbnormalList) {
                if (Objects.equals(ma.getAbnormalType(), MachineAbnormalConstant.MACHINE_ABNORMAL_CCQY)) {
                    temp = MachinePosConstant.POS_AREA_OUT;
                    break;
                } else if (Objects.equals(ma.getAbnormalType(), MachineAbnormalConstant.MACHINE_ABNORMAL_ZW)) {
                    temp = MachinePosConstant.POS_AREA_IN;
                    break;
                }
            }
        }
        machineShowStatus.setMachineParkState(temp);
    }

    public MachineLastUse getMachineLastUse() {
        return machineLastUse;
    }

    public void setMachineLastUse(MachineLastUse machineLastUse) {
        this.machineLastUse = machineLastUse;
    }

    public MachineStatus getMachineStatus() {
        return machineStatus;
    }

    public void setMachineStatus(MachineStatus machineStatus) {
        this.machineStatus = machineStatus;
    }

    public RideLogEx getRideLog() {
        return rideLog;
    }

    public void setRideLog(RideLogEx rideLog) {
        this.rideLog = rideLog;
    }

    public ParkPoint getParkPoint() {
        return parkPoint;
    }

    public void setParkPoint(ParkPoint parkPoint) {
        this.parkPoint = parkPoint;
    }

    public MachineShowStatus getMachineShowStatus() {
        return machineShowStatus;
    }

    public void setMachineShowStatus(MachineShowStatus machineShowStatus) {
        this.machineShowStatus = machineShowStatus;
    }

    public Integer getMachineFunctionType() {
        return machineFunctionType;
    }

    public void setMachineFunctionType(Integer machineFunctionType) {
        this.machineFunctionType = machineFunctionType;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    @Override
    public String toString() {
        return "MachineInfo [machineStatus=" + machineStatus + ", rideLog=" + rideLog + ", parkPoint=" + parkPoint + ", machineShowStatus=" + machineShowStatus + "]";
    }

}
